*******************************************
*** Minority MPs in the German Bundestag **
*** Bailer, Breunig, Giger, Wuest        **
*** 2020-08-31                          **
*******************************************
 
** setup
* packages (if needed)

ssc install bspline
ssc install polyspline
ssc install postrcspline


* data 
use BBGW_BJPS_dataset.dta, clear

********************************************************************************************************
***********************************************************************************************************

*Table 2
nbreg q_gender sex sen  position direct_mandate electionyear incumbent cubsp*,  robust nolog
nbreg q_migrant visible sen  position direct_mandate electionyear incumbent cubsp*, robust nolog
nbreg q_income lowoccu sen  position direct_mandate electionyear incumbent cubsp*,  robust nolog
nbreg q_age young35 sen  position direct_mandate electionyear incumbent cubsp*,  robust nolog


* Table 3
nbreg q_gender sex##c.sen  position direct_mandate electionyear incumbent cubsp*,  robust nolog
margins sex, at (sen=(1 (4) 60)) 
marginsplot, scheme(s1mono) xscale(range(0 0.2)) xtitle(Seniority (in quarters))  title(Gender Model)   legend(position(12) region(lcolor(white)))

nbreg q_migrant visible##c.sen  position direct_mandate electionyear incumbent cubsp*, robust nolog
margins visible, at (sen=(1 (4) 60)) 
marginsplot, scheme(s1mono) xtitle(Seniority (in quarters)) title(Migrant Model)   legend(position(12) region(lcolor(white)))

nbreg q_income lowoccu##c.sen position direct_mandate electionyear incumbent cubsp*,  robust nolog
margins lowoccu, at (sen=(1 (4) 60)) 
marginsplot, scheme(s1mono) xtitle(Seniority (in quarters))  title(Low Social Class Model)   legend(position(12) region(lcolor(white)))

nbreg q_age young35##c.sen  position direct_mandate electionyear incumbent cubsp*,  robust nolog
margins young35, at (sen=(1 (4) 60)) 
marginsplot, scheme(s1mono) xtitle(Seniority (in quarters)) title(Age Model)   legend(position(12) region(lcolor(white)))


*************************************************************************************
*Supplementary Material

*Table A1
*Model with different operationalization of migrant
nbreg q_migrant migrant sen  position direct_mandate electionyear incumbent cubsp*, robust nolog
nbreg q_migrant migrant##c.sen  position direct_mandate electionyear incumbent cubsp*, robust nolog


*Table A2
*Model with different operationalization of low social class: ISEI

nbreg q_income isei_low c.sen position direct_mandate electionyear incumbent cubsp*,  robust nolog
nbreg q_income isei_low##c.sen position direct_mandate electionyear incumbent cubsp*,  robust nolog
margins isei_low, at (sen=(1 (4) 60)) 
marginsplot, scheme(s1mono) xtitle(Seniority (in quarters))  title(Low Social Class Model)   legend(position(12) region(lcolor(white)))


*Table A3
*Models with party dummies

nbreg q_gender sex##c.sen  position direct_mandate electionyear party1 party4 party5 party6 cubsp*,  robust nolog
nbreg q_migrant visible##c.sen position direct_mandate electionyear party1 party4 party5 party6 cubsp*,  robust nolog
nbreg q_income lowoccu##c.sen position direct_mandate electionyear party1 party4 party5 party6 cubsp* ,robust nolog
nbreg q_age young35##c.sen  position direct_mandate electionyear party1 party4 party5 party6 cubsp*,  robust nolog


*Table A4
*Models without 1-term-MPs
preserve
bys id: egen maxsen=max(sen)
tab maxsen
drop if maxsen <=16

nbreg q_gender sex##c.sen  position direct_mandate electionyear incumbent cubsp*,  robust nolog
nbreg q_migrant visible##c.sen  position direct_mandate electionyear incumbent cubsp*, robust nolog
nbreg q_income lowoccu##c.sen position direct_mandate electionyear incumbent cubsp*,  robust nolog
nbreg q_age young35##c.sen  position direct_mandate electionyear incumbent cubsp*,  robust nolog

restore

*Table A5
*Models without CAP categories 200 and 500
use combined_quarterly_new3.dta, clear

nbreg gender_no200 sex##c.sen  position direct_mandate electionyear incumbent cubsp*,  robust
nbreg migrant_no200 visible##c.sen  position direct_mandate electionyear incumbent cubsp*, robust
nbreg age_no200 young35##c.sen  position direct_mandate electionyear incumbent cubsp*,  robust


************************************************************************3
*************************************************************************
